package com.baida.retail.tasksystem.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration //需要加载这个配置类--把这个bean放到ioc中去
@EnableSwagger2 //启用Swagger2
public class SwaggerConfig {

    /**
     * 配置只扫描controller层的包
     * @return
     */
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.baida.retail.tasksystem.controller"))
                .build()
                ;
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("基础工厂模块 API")
                .description("springboot-swagger2 在线借口文档")
                .termsOfServiceUrl("https://www.codingme.net")
                .version("1.2")
                .build();
    }
}
